//
//  UIImageView+HQSave.m
//  XiRan-iOS
//
//  Created by 韩强 on 12/31/19.
//  Copyright © 2019 Wood. All rights reserved.
//

#import "UIImageView+HQSave.h"

@interface UIImageView () <UIActionSheetDelegate>

@end
@implementation UIImageView (HQSave)
- (instancetype)init {
    if (self = [super init]) {
        self.userInteractionEnabled = YES;
//        UILongPressGestureRecognizer *lonTap = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
//        lonTap.minimumPressDuration = 1;
//        [self addGestureRecognizer:lonTap];
        self.contentMode = UIViewContentModeScaleAspectFit;

    }
    return self;
}
//
//- (void)longPress:(UILongPressGestureRecognizer *)gesture {
//    // 一般开发中,长按操作只会做一次
//    // 假设在一开始长按的时候就做一次操作
//
//    if (gesture.state == UIGestureRecognizerStateBegan) {
//
//        UIActionSheet *as = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:[[MWConfigManager manager] objectForKey:@"cancel" defaultValue:@"取消"]  destructiveButtonTitle:nil otherButtonTitles:[[MWConfigManager manager] objectForKey:@"save_album" defaultValue:@"保存到相册"], nil];
//        [as showInView:[UIApplication sharedApplication].keyWindow];
//
//    }
//}
//
//- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex  {
//    if (buttonIndex == 0) {
//        NSError *error = nil;
//
//        [[PHPhotoLibrary sharedPhotoLibrary] performChangesAndWait:^{
//
//           [PHAssetChangeRequest creationRequestForAssetFromImage:self.image];
//
//        } error:&error];
//
//        if (error) {
//        }else{
//              MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[UIApplication sharedApplication].keyWindow animated:YES];
//              hud.mode = MBProgressHUDModeText;
//              hud.label.text = [[MWConfigManager manager] objectForKey:@"saved_successfully" defaultValue:@"保存成功"];
//              [hud hideAnimated:YES afterDelay:2];
//        }
//    }
//}

@end
